

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>手动部署 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="在 FreeBSD 上手动部署" href="../manual-freebsd-deployment/" />
    <link rel="prev" title="为块设备安装虚拟化支持" href="../install-vm-cloud/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../">安装 Ceph</a> &raquo;</li>
        
          <li><a href="../index_manual/">安装（手动）</a> &raquo;</li>
        
      <li>手动部署</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/install/manual-deployment.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">安装 Ceph</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#id1">建议的方法</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id2">其他方法</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="../index_manual/">安装（手动）</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id2">获取软件</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id3">安装软件</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../index_manual/#id4">手动部署一套集群</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id5">升级软件</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#windows">Windows</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="id1">
<h1>手动部署<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>所有 Ceph 集群都需要至少一个监视器、
和数量不小于副本数的 OSD 。自举引导初始监视器是部署 Ceph 存储集群的第一步，
监视器的部署也为整个集群奠定了重要框架，
如存储池副本数、每个 OSD 拥有的归置组数量、心跳周期、
是否需认证等，其中大多数选项都有默认值，
但是建设生产集群时仍需要您熟知它们。</p>
<p>我们将配置起监视器为 <code class="docutils literal notranslate"><span class="pre">mon-node1</span></code> ， OSD 节点为 <code class="docutils literal notranslate"><span class="pre">osd-node1</span></code> 、
<code class="docutils literal notranslate"><span class="pre">osd-node2</span></code> 的集群。</p>
<div class="section" id="id2">
<h2>监视器的自举引导<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>自举引导监视器（理论上是 Ceph 存储集群）
需要以下几个条件：</p>
<ul>
<li><p><strong>惟一标识符：</strong> <code class="docutils literal notranslate"><span class="pre">fsid</span></code> 是集群的惟一标识，
它是 Ceph 作为文件系统时的文件系统标识符。
现在， Ceph 还支持原生接口、块设备、和对象存储网关接口，
所以 <code class="docutils literal notranslate"><span class="pre">fsid</span></code> 有点名不符实了。</p></li>
<li><p><strong>集群名称：</strong> 每个 Ceph 集群都有自己的名字，
它是个不含空格的字符串。
默认名字是 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 、但你可以更改；
尤其是运营着多个集群时，覆盖默认集群名特别重要，
而且你得清楚地知道正在操作哪一个。</p>
<p>比如，当你在一个<a class="reference internal" href="../../radosgw/multisite/#multisite"><span class="std std-ref">多站配置</span></a>中运营多个集群时，
集群名字（如 <code class="docutils literal notranslate"><span class="pre">us-west</span></code> 、 <code class="docutils literal notranslate"><span class="pre">us-east</span></code> ）将作为标识符出现在 CLI 界面上。
<strong>注意：</strong>要在命令行下指定某个集群，
可以指定以集群名为前缀的配置文件（如
<code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> 、 <code class="docutils literal notranslate"><span class="pre">us-west.conf</span></code> 、 <code class="docutils literal notranslate"><span class="pre">us-east.conf</span></code> 等）；
也可以参考 CLI 用法（ <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">--cluster</span> <span class="pre">{cluster-name}</span></code> ）。</p>
</li>
<li><p><strong>监视器名字：</strong> 同一集群内的各监视器例程都有惟一的名字，通常都用主机名作为监视器名字（我们建议每台主机只运行一个监视器、并且不要与 OSD 主机复用。短主机名可以用
<code class="docutils literal notranslate"><span class="pre">hostname</span> <span class="pre">-s</span></code> 获取。</p></li>
<li><p><strong>监视器图：</strong> 自举引导初始监视器需要生成监视器图，
为此，需要有 <code class="docutils literal notranslate"><span class="pre">fsid</span></code> 、集群名（或用默认）、
至少一个主机名及其 IP 。</p></li>
<li><p><strong>监视器密钥环：</strong> 监视器之间通过密钥通讯，
所以你必须把监视器密钥加入密钥环，
并在自举引导时提供。</p></li>
<li><p><strong>管理密钥环：</strong> 要使用 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 这个命令行工具，
你必须有 <code class="docutils literal notranslate"><span class="pre">client.admin</span></code> 用户，所以你要创建此用户及其密钥，
并把他们加入密钥环。</p></li>
</ul>
<p>前述必要条件并未提及 Ceph 配置文件的创建，
然而，实践中最好创建个配置文件，并写好
<code class="docutils literal notranslate"><span class="pre">fsid</span></code> 、 <code class="docutils literal notranslate"><span class="pre">mon</span> <span class="pre">initial</span> <span class="pre">members</span></code> 和
<code class="docutils literal notranslate"><span class="pre">mon</span> <span class="pre">host</span></code> 配置。</p>
<p>你也可以查看或设置监视器所有的运行时配置。
Ceph 配置文件可能只包含非默认配置。
Ceph 配置文件的配置将覆盖默认值，
把这些配置保存在配置文件里可简化维护。</p>
<p>具体过程如下：</p>
<ol class="arabic">
<li><p>登录到初始监视器节点：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
</pre></div>
</div>
<p>如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">mon</span><span class="o">-</span><span class="n">node1</span>
</pre></div>
</div>
</li>
<li><p>确保保存 Ceph 配置文件的目录存在， Ceph 默认使用
<code class="docutils literal notranslate"><span class="pre">/etc/ceph</span></code> 。安装 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 软件时，安装器也会自动创建
<code class="docutils literal notranslate"><span class="pre">/etc/ceph/</span></code> 目录。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ls</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span>
</pre></div>
</div>
</li>
<li><p>创建 Ceph 配置文件， Ceph 默认使用 <code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> ，
其中的 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 是集群名字。
在配置文件里加这一行 [global]</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">vim</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">conf</span>
</pre></div>
</div>
</li>
<li><p>给集群分配惟一 ID （即 <code class="docutils literal notranslate"><span class="pre">fsid</span></code> ）。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">uuidgen</span>
</pre></div>
</div>
</li>
<li><p>把此 ID 写入 Ceph 配置文件。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fsid</span> <span class="o">=</span> <span class="p">{</span><span class="n">UUID</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fsid</span> <span class="o">=</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
</pre></div>
</div>
</li>
<li><p>把初始监视器写入 Ceph 配置文件。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}[,{</span><span class="n">hostname</span><span class="p">}]</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="n">mon</span><span class="o">-</span><span class="n">node1</span>
</pre></div>
</div>
</li>
<li><p>把初始监视器的 IP 地址写入 Ceph 配置文件、
并保存。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}[,{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}]</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="mf">192.168.0.1</span>
</pre></div>
</div>
<p><strong>注意：</strong> 你可以用 IPv6 地址取代 IPv4 地址，
但必须设置 <code class="docutils literal notranslate"><span class="pre">ms</span> <span class="pre">bind</span> <span class="pre">ipv6</span> <span class="pre">=</span> <span class="pre">true</span></code> 。
详情见<a class="reference external" href="../../rados/configuration/network-config-ref">网络配置参考</a>。</p>
</li>
<li><p>为此集群创建密钥环、并生成监视器密钥。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">--</span><span class="n">create</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">key</span> <span class="o">-</span><span class="n">n</span> <span class="n">mon</span><span class="o">.</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mon</span> <span class="s1">&#39;allow *&#39;</span>
</pre></div>
</div>
</li>
<li><p>生成管理员密钥环，生成 <code class="docutils literal notranslate"><span class="pre">client.admin</span></code> 用户并加入密钥环。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">--</span><span class="n">create</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">admin</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">key</span> <span class="o">-</span><span class="n">n</span> <span class="n">client</span><span class="o">.</span><span class="n">admin</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mon</span> <span class="s1">&#39;allow *&#39;</span> <span class="o">--</span><span class="n">cap</span> <span class="n">osd</span> <span class="s1">&#39;allow *&#39;</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mds</span> <span class="s1">&#39;allow *&#39;</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mgr</span> <span class="s1">&#39;allow *&#39;</span>
</pre></div>
</div>
</li>
<li><p>生成一个 bootstrap-osd 密钥环、生成一个
<code class="docutils literal notranslate"><span class="pre">client.bootstrap-osd</span></code> 用户并把此用户加入密钥环。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">--</span><span class="n">create</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">bootstrap</span><span class="o">-</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">key</span> <span class="o">-</span><span class="n">n</span> <span class="n">client</span><span class="o">.</span><span class="n">bootstrap</span><span class="o">-</span><span class="n">osd</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mon</span> <span class="s1">&#39;profile bootstrap-osd&#39;</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mgr</span> <span class="s1">&#39;allow r&#39;</span>
</pre></div>
</div>
</li>
<li><p>把生成的密钥加进 <code class="docutils literal notranslate"><span class="pre">ceph.mon.keyring</span></code> 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">import</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">admin</span><span class="o">.</span><span class="n">keyring</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">import</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">bootstrap</span><span class="o">-</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>更改 <code class="docutils literal notranslate"><span class="pre">ceph.mon.keyring</span></code> 的所有者：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">chown</span> <span class="n">ceph</span><span class="p">:</span><span class="n">ceph</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>用规划好的主机名、对应 IP 地址、和 FSID 生成一个监视器图，并保存为 <code class="docutils literal notranslate"><span class="pre">/tmp/monmap</span></code> 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">monmaptool</span> <span class="o">--</span><span class="n">create</span> <span class="o">--</span><span class="n">add</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}</span> <span class="o">--</span><span class="n">fsid</span> <span class="p">{</span><span class="n">uuid</span><span class="p">}</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">monmaptool</span> <span class="o">--</span><span class="n">create</span> <span class="o">--</span><span class="n">add</span> <span class="n">mon</span><span class="o">-</span><span class="n">node1</span> <span class="mf">192.168.0.1</span> <span class="o">--</span><span class="n">fsid</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span>
</pre></div>
</div>
</li>
<li><p>在监视器主机上分别创建数据目录。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">mkdir</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mon</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="o">-</span><span class="n">u</span> <span class="n">ceph</span> <span class="n">mkdir</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mon</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="n">mon</span><span class="o">-</span><span class="n">node1</span>
</pre></div>
</div>
<p>详情见<a class="reference external" href="../../rados/configuration/mon-config-ref#data">监视器配置参考——数据</a>。</p>
</li>
<li><p>用监视器图和密钥环组装守护进程所需的初始数据。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="o">-</span><span class="n">u</span> <span class="n">ceph</span> <span class="n">ceph</span><span class="o">-</span><span class="n">mon</span> <span class="p">[</span><span class="o">--</span><span class="n">cluster</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="o">--</span><span class="n">mkfs</span> <span class="o">-</span><span class="n">i</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span> <span class="o">--</span><span class="n">monmap</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span> <span class="o">--</span><span class="n">keyring</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="o">-</span><span class="n">u</span> <span class="n">ceph</span> <span class="n">ceph</span><span class="o">-</span><span class="n">mon</span> <span class="o">--</span><span class="n">mkfs</span> <span class="o">-</span><span class="n">i</span> <span class="n">mon</span><span class="o">-</span><span class="n">node1</span> <span class="o">--</span><span class="n">monmap</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span> <span class="o">--</span><span class="n">keyring</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>仔细斟酌 Ceph 配置文件，公共的全局配置包括这些：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="k">global</span><span class="p">]</span>
<span class="n">fsid</span> <span class="o">=</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="nb">id</span><span class="p">}</span>
<span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}[,</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}]</span>
<span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}[,</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}]</span>
<span class="n">public</span> <span class="n">network</span> <span class="o">=</span> <span class="p">{</span><span class="n">network</span><span class="p">}[,</span> <span class="p">{</span><span class="n">network</span><span class="p">}]</span>
<span class="n">cluster</span> <span class="n">network</span> <span class="o">=</span> <span class="p">{</span><span class="n">network</span><span class="p">}[,</span> <span class="p">{</span><span class="n">network</span><span class="p">}]</span>
<span class="n">auth</span> <span class="n">cluster</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">service</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">client</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">osd</span> <span class="n">journal</span> <span class="n">size</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">size</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>  <span class="c1"># Write an object n times.</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="nb">min</span> <span class="n">size</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span> <span class="c1"># 在降级状态下允许写 n 个副本</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pg</span> <span class="n">num</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pgp</span> <span class="n">num</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
<span class="n">osd</span> <span class="n">crush</span> <span class="n">chooseleaf</span> <span class="nb">type</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
</pre></div>
</div>
<p>按前述实例， <code class="docutils literal notranslate"><span class="pre">[global]</span></code> 段的配置大致如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="k">global</span><span class="p">]</span>
<span class="n">fsid</span> <span class="o">=</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
<span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="n">mon</span><span class="o">-</span><span class="n">node1</span>
<span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="mf">192.168.0.1</span>
<span class="n">public</span> <span class="n">network</span> <span class="o">=</span> <span class="mf">192.168.0.0</span><span class="o">/</span><span class="mi">24</span>
<span class="n">auth</span> <span class="n">cluster</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">service</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">client</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">osd</span> <span class="n">journal</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">1024</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">3</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="nb">min</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pg</span> <span class="n">num</span> <span class="o">=</span> <span class="mi">333</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pgp</span> <span class="n">num</span> <span class="o">=</span> <span class="mi">333</span>
<span class="n">osd</span> <span class="n">crush</span> <span class="n">chooseleaf</span> <span class="nb">type</span> <span class="o">=</span> <span class="mi">1</span>
</pre></div>
</div>
</li>
<li><p>启动监视器。</p>
<p>用 systemd 启动服务：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">systemctl</span> <span class="n">start</span> <span class="n">ceph</span><span class="o">-</span><span class="n">mon</span><span class="nd">@mon</span><span class="o">-</span><span class="n">node1</span>
</pre></div>
</div>
</li>
<li><p>确认下集群在运行。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span> <span class="o">-</span><span class="n">s</span>
</pre></div>
</div>
<p>你应该从输出里看到刚刚启动的监视器在正常运行，并且应该会看到一个健康错误：它表明归置组卡在了 <code class="docutils literal notranslate"><span class="pre">stuck</span> <span class="pre">inactive</span></code>
状态。输出大致如此：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cluster</span><span class="p">:</span>
  <span class="nb">id</span><span class="p">:</span>     <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
  <span class="n">health</span><span class="p">:</span> <span class="n">HEALTH_OK</span>

<span class="n">services</span><span class="p">:</span>
  <span class="n">mon</span><span class="p">:</span> <span class="mi">1</span> <span class="n">daemons</span><span class="p">,</span> <span class="n">quorum</span> <span class="n">mon</span><span class="o">-</span><span class="n">node1</span>
  <span class="n">mgr</span><span class="p">:</span> <span class="n">mon</span><span class="o">-</span><span class="n">node1</span><span class="p">(</span><span class="n">active</span><span class="p">)</span>
  <span class="n">osd</span><span class="p">:</span> <span class="mi">0</span> <span class="n">osds</span><span class="p">:</span> <span class="mi">0</span> <span class="n">up</span><span class="p">,</span> <span class="mi">0</span> <span class="ow">in</span>

<span class="n">data</span><span class="p">:</span>
  <span class="n">pools</span><span class="p">:</span>   <span class="mi">0</span> <span class="n">pools</span><span class="p">,</span> <span class="mi">0</span> <span class="n">pgs</span>
  <span class="n">objects</span><span class="p">:</span> <span class="mi">0</span> <span class="n">objects</span><span class="p">,</span> <span class="mi">0</span> <span class="nb">bytes</span>
  <span class="n">usage</span><span class="p">:</span>   <span class="mi">0</span> <span class="n">kB</span> <span class="n">used</span><span class="p">,</span> <span class="mi">0</span> <span class="n">kB</span> <span class="o">/</span> <span class="mi">0</span> <span class="n">kB</span> <span class="n">avail</span>
  <span class="n">pgs</span><span class="p">:</span>
</pre></div>
</div>
<p><strong>注意：</strong> 一旦你添加了 OSD 并启动，归置组健康错误应该消失，
详情见<a class="reference internal" href="#osd">添加 OSD</a>。</p>
</li>
</ol>
</div>
<div class="section" id="id3">
<h2>管理器守护进程配置<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>在每个运行 ceph-mon 守护进程的节点上，应该同时配置起一个 ceph-mgr 守护进程。</p>
<p>请参考 <a class="reference internal" href="../../mgr/administrator/#mgr-administrator-guide"><span class="std std-ref">ceph-mgr 管理员指南</span></a> 。</p>
</div>
<div class="section" id="osd">
<h2>添加 OSD<a class="headerlink" href="#osd" title="Permalink to this headline">¶</a></h2>
<p>你的初始监视器可以正常运行后就可以添加 OSD 了。要想让集群达到
<code class="docutils literal notranslate"><span class="pre">active</span> <span class="pre">+</span> <span class="pre">clean</span></code> 状态，必须安装足够多的 OSD 来处理对象副本（如 <code class="docutils literal notranslate"><span class="pre">osd</span> <span class="pre">pool</span> <span class="pre">default</span> <span class="pre">size</span> <span class="pre">=</span> <span class="pre">2</span></code> 需要至少 2 个 OSD ）。在完成监视器自举引导后，集群就有了默认的 CRUSH 图，但现在此图还是空的，里面没有任何 OSD 映射到 Ceph 节点。</p>
<div class="section" id="id4">
<h3>精简型<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
<p>Ceph 软件包提供了 <code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code> 工具，可为 Ceph 准备好逻辑卷、硬盘或分区。
<code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code> 可通过递增索引来创建 OSD ID ；
还能把新 OSD 加入 CRUSH 图内的主机之下。
详细用法可参考 <code class="docutils literal notranslate"><span class="pre">ceph-volume</span> <span class="pre">-h</span></code> ，
此工具把后面将提到的<a class="reference internal" href="#id5">细致型</a>里面的步骤都自动化了。
为按照精简型创建前两个 OSD ，为各 OSD 执行下列命令：</p>
<div class="section" id="bluestore">
<h4>bluestore 后端<a class="headerlink" href="#bluestore" title="Permalink to this headline">¶</a></h4>
<ol class="arabic">
<li><p>创建 OSD 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">copy</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">bootstrap</span><span class="o">-</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">keyring</span> <span class="kn">from</span> <span class="nn">monitor</span> <span class="n">node</span> <span class="p">(</span><span class="n">mon</span><span class="o">-</span><span class="n">node1</span><span class="p">)</span> <span class="n">to</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">bootstrap</span><span class="o">-</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">keyring</span> <span class="n">on</span> <span class="n">osd</span> <span class="n">node</span> <span class="p">(</span><span class="n">osd</span><span class="o">-</span><span class="n">node1</span><span class="p">)</span>
<span class="n">ssh</span> <span class="p">{</span><span class="n">osd</span> <span class="n">node</span><span class="p">}</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">create</span> <span class="o">--</span><span class="n">data</span> <span class="p">{</span><span class="n">data</span><span class="o">-</span><span class="n">path</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">scp</span> <span class="o">-</span><span class="mi">3</span> <span class="n">root</span><span class="nd">@mon</span><span class="o">-</span><span class="n">node1</span><span class="p">:</span><span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">bootstrap</span><span class="o">-</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">keyring</span> <span class="n">root</span><span class="nd">@osd</span><span class="o">-</span><span class="n">node1</span><span class="p">:</span><span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">bootstrap</span><span class="o">-</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">keyring</span>

<span class="n">ssh</span> <span class="n">osd</span><span class="o">-</span><span class="n">node1</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">create</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">hdd1</span>
</pre></div>
</div>
</li>
</ol>
<p>或者，可以把创建过程分拆成两步（准备和激活）：</p>
<ol class="arabic">
<li><p>准备 OSD 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">node</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">data</span> <span class="p">{</span><span class="n">data</span><span class="o">-</span><span class="n">path</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">osd</span><span class="o">-</span><span class="n">node1</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">hdd1</span>
</pre></div>
</div>
<p>准备完成后，已准备好的 OSD 的 <code class="docutils literal notranslate"><span class="pre">ID</span></code> 和 <code class="docutils literal notranslate"><span class="pre">FSID</span></code> 是激活所必需的。
它们可以通过罗列当前服务器上的 OSD 获得：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="nb">list</span>
</pre></div>
</div>
</li>
<li><p>激活此 OSD：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">activate</span> <span class="p">{</span><span class="n">ID</span><span class="p">}</span> <span class="p">{</span><span class="n">FSID</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">activate</span> <span class="mi">0</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="filestore">
<h4>filestore 后端<a class="headerlink" href="#filestore" title="Permalink to this headline">¶</a></h4>
<ol class="arabic">
<li><p>创建 OSD 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">node</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">create</span> <span class="o">--</span><span class="n">filestore</span> <span class="o">--</span><span class="n">data</span> <span class="p">{</span><span class="n">data</span><span class="o">-</span><span class="n">path</span><span class="p">}</span> <span class="o">--</span><span class="n">journal</span> <span class="p">{</span><span class="n">journal</span><span class="o">-</span><span class="n">path</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">osd</span><span class="o">-</span><span class="n">node1</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">create</span> <span class="o">--</span><span class="n">filestore</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">hdd1</span> <span class="o">--</span><span class="n">journal</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">hdd2</span>
</pre></div>
</div>
</li>
</ol>
<p>或者，可以把创建过程分拆成两步（准备和激活）：</p>
<ol class="arabic">
<li><p>准备 OSD 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">node</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">filestore</span> <span class="o">--</span><span class="n">data</span> <span class="p">{</span><span class="n">data</span><span class="o">-</span><span class="n">path</span><span class="p">}</span> <span class="o">--</span><span class="n">journal</span> <span class="p">{</span><span class="n">journal</span><span class="o">-</span><span class="n">path</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">osd</span><span class="o">-</span><span class="n">node1</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">filestore</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">hdd1</span> <span class="o">--</span><span class="n">journal</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">hdd2</span>
</pre></div>
</div>
<p>准备完成后，已准备好的 OSD 的 <code class="docutils literal notranslate"><span class="pre">ID</span></code> 和 <code class="docutils literal notranslate"><span class="pre">FSID</span></code> 是激活所必需的。它们可以通过罗列当前服务器上的 OSD 获得：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="nb">list</span>
</pre></div>
</div>
</li>
<li><p>激活 OSD：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">activate</span> <span class="o">--</span><span class="n">filestore</span> <span class="p">{</span><span class="n">ID</span><span class="p">}</span> <span class="p">{</span><span class="n">FSID</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">activate</span> <span class="o">--</span><span class="n">filestore</span> <span class="mi">0</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
</pre></div>
</div>
</li>
</ol>
</div>
</div>
<div class="section" id="id5">
<h3>细致型<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h3>
<p>要是不想借助任何辅助工具，可按下列步骤创建 OSD 、将之加入集群和
CRUSH 图。对于每个 OSD ，执行下列详细步骤。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>本过程不涉及使用 dm-crypt “密码箱”
实现基于 dm-crypt 的部署。</p>
</div>
<ol class="arabic">
<li><p>登录到 OSD 主机、并切换为 root 用户。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">node</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
<span class="n">sudo</span> <span class="n">bash</span>
</pre></div>
</div>
</li>
<li><p>给 OSD 生成 UUID 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>UUID=$(uuidgen)
</pre></div>
</div>
</li>
<li><p>给 OSD 生成 cephx 密钥。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>OSD_SECRET=$(ceph-authtool --gen-print-key)
</pre></div>
</div>
</li>
<li><p>创建 OSD 。注意，如果你想重用先前已销毁 OSD 的 id ，
可以给 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">osd</span> <span class="pre">new</span></code> 命令再加上 OSD ID 参数。
我们假设 <code class="docutils literal notranslate"><span class="pre">client.bootstrap-osd</span></code> 密钥已存在于目标机器上。
或者，你可以在持有此密钥的其它主机上、
以 <code class="docutils literal notranslate"><span class="pre">client.admin</span></code> 身份执行这个命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>ID=$(echo &quot;{\&quot;cephx_secret\&quot;: \&quot;$OSD_SECRET\&quot;}&quot; | \
ceph osd new $UUID -i - \
-n client.bootstrap-osd -k /var/lib/ceph/bootstrap-osd/ceph.keyring)
</pre></div>
</div>
<p>还可以在 JSON 里加一个 <code class="docutils literal notranslate"><span class="pre">crush_device_class</span></code> 属性
来设置一个默认值（基于自动探测到的设备类型生成的 <code class="docutils literal notranslate"><span class="pre">ssd</span></code> 或 <code class="docutils literal notranslate"><span class="pre">hdd</span></code> ）
以外的初始类。</p>
</li>
<li><p>在新 OSD 主机上创建默认目录。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>mkdir /var/lib/ceph/osd/ceph-$ID
</pre></div>
</div>
</li>
<li><p>如果要把 OSD 装到非系统盘的独立硬盘上，先创建文件系统、
然后挂载到刚创建的目录下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>mkfs.xfs /dev/{DEV}
mount /dev/{DEV} /var/lib/ceph/osd/ceph-$ID
</pre></div>
</div>
</li>
<li><p>把密钥写入 OSD 密钥环文件：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-$ID/keyring \
     --name osd.$ID --add-key $OSD_SECRET
</pre></div>
</div>
</li>
<li><p>初始化 OSD 数据目录：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>ceph-osd -i $ID --mkfs --osd-uuid $UUID
</pre></div>
</div>
</li>
<li><p>修正所有权：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>chown -R ceph:ceph /var/lib/ceph/osd/ceph-$ID
</pre></div>
</div>
</li>
<li><p>把 OSD 加入 Ceph 后， OSD 已经在配置里了。但它还没开始运行，
要启动这个新 OSD 它才能收数据。</p>
<p>在基于 systemd 的发行版上：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>systemctl enable ceph-osd@$ID
systemctl start ceph-osd@$ID
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">systemctl</span> <span class="n">enable</span> <span class="n">ceph</span><span class="o">-</span><span class="n">osd</span><span class="o">@</span><span class="mi">12</span>
<span class="n">systemctl</span> <span class="n">start</span> <span class="n">ceph</span><span class="o">-</span><span class="n">osd</span><span class="o">@</span><span class="mi">12</span>
</pre></div>
</div>
</li>
</ol>
</div>
</div>
<div class="section" id="mds">
<h2>添加 MDS<a class="headerlink" href="#mds" title="Permalink to this headline">¶</a></h2>
<p>在下面的命令中， <code class="docutils literal notranslate"><span class="pre">{id}</span></code> 可以是任意名字，如此机器的主机名。</p>
<ol class="arabic">
<li><p>创建 MDS 数据目录：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mkdir</span> <span class="o">-</span><span class="n">p</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mds</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>创建密钥环：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">--</span><span class="n">create</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mds</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span><span class="o">/</span><span class="n">keyring</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">key</span> <span class="o">-</span><span class="n">n</span> <span class="n">mds</span><span class="o">.</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>导入密钥环并设置能力：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">auth</span> <span class="n">add</span> <span class="n">mds</span><span class="o">.</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span> <span class="n">osd</span> <span class="s2">&quot;allow rwx&quot;</span> <span class="n">mds</span> <span class="s2">&quot;allow *&quot;</span> <span class="n">mon</span> <span class="s2">&quot;allow profile mds&quot;</span> <span class="o">-</span><span class="n">i</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mds</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span><span class="o">/</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>写进 ceph.conf ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">mds</span><span class="o">.</span><span class="p">{</span><span class="nb">id</span><span class="p">}]</span>
<span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>手动启动守护进程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">mds</span> <span class="o">--</span><span class="n">cluster</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="o">-</span><span class="n">i</span> <span class="p">{</span><span class="nb">id</span><span class="p">}</span> <span class="o">-</span><span class="n">m</span> <span class="p">{</span><span class="n">mon</span><span class="o">-</span><span class="n">hostname</span><span class="p">}:{</span><span class="n">mon</span><span class="o">-</span><span class="n">port</span><span class="p">}</span> <span class="p">[</span><span class="o">-</span><span class="n">f</span><span class="p">]</span>
</pre></div>
</div>
</li>
<li><p>常规方式启动守护进程（通过 ceph.conf 的配置）。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">service</span> <span class="n">ceph</span> <span class="n">start</span>
</pre></div>
</div>
</li>
<li><p>如果启动失败，报错如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mds</span><span class="o">.-</span><span class="mf">1.0</span> <span class="n">ERROR</span><span class="p">:</span> <span class="n">failed</span> <span class="n">to</span> <span class="n">authenticate</span><span class="p">:</span> <span class="p">(</span><span class="mi">22</span><span class="p">)</span> <span class="n">Invalid</span> <span class="n">argument</span>
</pre></div>
</div>
<p>那么，你得确认： ceph.conf 的 global 段下没有密钥环配置；
把此配置挪到客户端配置段下，或者给这个 MDS 守护进程配置单独的密钥环。
还得确保 MDS 数据目录内的密钥与 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">auth</span> <span class="pre">get</span> <span class="pre">mds.{id}</span></code> 输出的相同。</p>
</li>
<li><p>现在准备好了，你可以<a class="reference external" href="../../cephfs/createfs">创建 Ceph 文件系统</a>了。</p></li>
</ol>
</div>
<div class="section" id="id6">
<h2>总结<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h2>
<p>监视器和两个 OSD 开始正常运行后，你就可以通过下列命令观察归置组互联过程了：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="o">-</span><span class="n">w</span>
</pre></div>
</div>
<p>执行下列命令查看 OSD树：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">tree</span>
</pre></div>
</div>
<p>你应该会看到类似如下的输出：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># id    weight  type name       up/down reweight</span>
<span class="o">-</span><span class="mi">1</span>      <span class="mi">2</span>       <span class="n">root</span> <span class="n">default</span>
<span class="o">-</span><span class="mi">2</span>      <span class="mi">2</span>               <span class="n">host</span> <span class="n">osd</span><span class="o">-</span><span class="n">node1</span>
<span class="mi">0</span>       <span class="mi">1</span>                       <span class="n">osd</span><span class="mf">.0</span>   <span class="n">up</span>      <span class="mi">1</span>
<span class="o">-</span><span class="mi">3</span>      <span class="mi">1</span>               <span class="n">host</span> <span class="n">osd</span><span class="o">-</span><span class="n">node2</span>
<span class="mi">1</span>       <span class="mi">1</span>                       <span class="n">osd</span><span class="mf">.1</span>   <span class="n">up</span>      <span class="mi">1</span>
</pre></div>
</div>
<p>要增加（或删除）额外监视器，参见<a class="reference external" href="../../rados/operations/add-or-rm-mons">增加/删除监视器</a>。
要增加（或删除）额外 OSD ，参见<a class="reference external" href="../../rados/operations/add-or-rm-osds">增加/删除 OSD</a> 。</p>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../manual-freebsd-deployment/" class="btn btn-neutral float-right" title="在 FreeBSD 上手动部署" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../install-vm-cloud/" class="btn btn-neutral float-left" title="为块设备安装虚拟化支持" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>